package pqsk.android.audio;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import gueei.binding.app.BindingActivity;
import pqsk.android.audio.ViewModels.vmAudioMixer;

public class AudioMixerActivity extends BindingActivity
{
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		this.setAndBindRootView(R.layout.main, new vmAudioMixer(this));
	}
	
	@Override
	protected void onStop()
	{
		super.onStop();
		
		// Change preferences
//		SharedPreferences settings = getSharedPreferences("MyParams", 0);
//		SharedPreferences.Editor editor = settings.edit();
//		editor.putBoolean("booleanParam", true);
//
//		// Save changes
//		editor.commit();
		SharedPreferences settings = PreferenceManager
		        .getDefaultSharedPreferences(getBaseContext());
		SharedPreferences.Editor editor = settings.edit();
		editor.commit();

	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item)
	{
		switch (item.getItemId())
		{
			case R.id.settings:
				Intent settingsActivity = new Intent(getBaseContext(),
				        AudioMixerSettingsActivity.class);
				this.startActivity(settingsActivity);
				break;
			case R.id.exit:
				this.finish();
				break;
		}// switch
		return true;
	}
	
}